]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Incorporate invisible borders into window dimming effect
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 17 Sep 2011 19:56:59 +0000 (15:56 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 19 Sep 2011 16:39:48 +0000 (12:39 -0400)
Without this, the dim "fade" will start at the top of the untrimmed actor. With
a large enough draggable_border_width setting, this will show no fade at all.

https://bugzilla.gnome.org/show_bug.cgi?id=659302

data/shaders/dim-window.glsl
js/ui/windowManager.js

index 2c95022efd785d9d489c89e46cb6ff6bf12794c8..5f9ad9c570f251919f08d65ae857e0b057060221 100644 (file)
@@ -1,5 +1,6 @@
 #version 110
 uniform sampler2D tex;
+uniform float startY;
 uniform float fraction;
 uniform float height;
 const float c = -0.2;
@@ -18,10 +19,11 @@ void main()
   // To reduce contrast, blend with a mid gray
   cogl_color_out = color * contrast - off * c;
 
-  // We only fully dim at a distance of BORDER_MAX_HEIGHT from the edge and
+  // We only fully dim at a distance of BORDER_MAX_HEIGHT from startY and
   // when the fraction is 1.0. For other locations and fractions we linearly
-  // interpolate back to the original undimmed color.
-  cogl_color_out = color + (cogl_color_out - color) * min(y / border_max_height, 1.0);
+  // interpolate back to the original undimmed color, so the top of the window
+  // is at full color.
+  cogl_color_out = color + (cogl_color_out - color) * max(min((y - startY) / border_max_height, 1.0), 0.0);
   cogl_color_out = color + (cogl_color_out - color) * fraction;
 
   cogl_color_out *= color.a;
index 48276fe08ff9a538364ddd478f1c7ebc99a2debd..2ca6deb81e5ec730fc65cc70ef3ce61e81ee6875 100644 (file)
@@ -25,15 +25,22 @@ function getDimShaderSource() {
     return dimShader;
 }
 
-function WindowDimmer(actor) {
-    this._init(actor);
+function getTopInvisibleBorder(metaWindow) {
+    let outerRect = metaWindow.get_outer_rect();
+    let inputRect = metaWindow.get_input_rect();
+    return outerRect.y - inputRect.y;
+}
+
+function WindowDimmer(actor, window) {
+    this._init(actor, window);
 }
 
 WindowDimmer.prototype = {
-    _init: function(actor) {
+    _init: function(actor, window) {
         this.effect = new Clutter.ShaderEffect({ shader_type: Clutter.ShaderType.FRAGMENT_SHADER });
         this.effect.set_shader_source(getDimShaderSource());
 
+        this.window = window;
         this.actor = actor;
     },
 
@@ -45,6 +52,7 @@ WindowDimmer.prototype = {
         }
 
         if (fraction > 0.01) {
+            Shell.shader_effect_set_double_uniform(this.effect, 'startY', getTopInvisibleBorder(this.window));
             Shell.shader_effect_set_double_uniform(this.effect, 'height', this.actor.get_height());
             Shell.shader_effect_set_double_uniform(this.effect, 'fraction', fraction);
 
@@ -63,9 +71,9 @@ WindowDimmer.prototype = {
     _dimFraction: 0.0
 };
 
-function getWindowDimmer(texture) {
+function getWindowDimmer(texture, window) {
     if (!texture._windowDimmer)
-        texture._windowDimmer = new WindowDimmer(texture);
+        texture._windowDimmer = new WindowDimmer(texture, window);
 
     return texture._windowDimmer;
 }
@@ -264,13 +272,13 @@ WindowManager.prototype = {
             return;
         let texture = actor.get_texture();
         if (animate)
-            Tweener.addTween(getWindowDimmer(texture),
+            Tweener.addTween(getWindowDimmer(texture, window),
                              { dimFraction: 1.0,
                                time: DIM_TIME,
                                transition: 'linear'
                              });
         else
-            getWindowDimmer(texture).dimFraction = 1.0;
+            getWindowDimmer(texture, window).dimFraction = 1.0;
     },
 
     _undimWindow: function(window, animate) {
@@ -279,13 +287,13 @@ WindowManager.prototype = {
             return;
         let texture = actor.get_texture();
         if (animate)
-            Tweener.addTween(getWindowDimmer(texture),
+            Tweener.addTween(getWindowDimmer(texture, window),
                              { dimFraction: 0.0,
                                time: UNDIM_TIME,
                                transition: 'linear'
                              });
         else
-            getWindowDimmer(texture).dimFraction = 0.0;
+            getWindowDimmer(texture, window).dimFraction = 0.0;
     },
 
     _mapWindow : function(shellwm, actor) {